package com.huajx.tb.handler;


import com.huajx.core.handler.HandlerAdapter;
import com.huajx.core.message.RequestMessage;
import com.huajx.core.message.ResponseMessage;
import com.huajx.tb.dto.NengLongMessage;
import com.huajx.util.date.DateTime;
import com.huajx.util.date.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class TimeCheckHandler extends AbstractNengLongHandler {
    protected final Logger logger = LoggerFactory.getLogger(TimeCheckHandler.class);

    public static final HandlerAdapter me = new TimeCheckHandler();

    private static final String pattern_ymdhms4 = "yyyyMMddHHmmss";

    @Override
    public ResponseMessage handler(RequestMessage request) {
//		NengLongMessage dto = getMessage(request.getMessage());
        String date = DateUtil.format(new DateTime(), pattern_ymdhms4);
//		render(request.getSession(), dto, date);
//		String response = "JTP" + MessageKit.getStr(dto.getBody(), 3, 23) + "00100C" + date + "01";
//		logger.info("同步服务器时间响应: {}",response);
//		request.getSession().write(response);

        render(request, date);
        return null;
    }

//	@Override
//	public ReplyBody process(LdSession session, SentBody sent) {
//
////		byte[] bytes = sent.getMessage();
//
////		String temp = MessageKit.getStr(bytes, 0, bytes.length);
//		String date = DateKit.format(new Date(), DateKit.pattern_ymdhms4);
////		String response = "JTP" + sent.get("serialNo") +sent.get("version")+sent.get("device_id") + "00100C" + date + "01";
////		String response = "JTP" + sent.get("serialNo") +sent.get("version")+sent.get("device_id") + "00080A" + "STATUS" + temp;
//		String response = "JTP" + MessageKit.getStr(sent.getMessage(), 3, 23) + "00100C" + date + "01";
//		logger.info("同步服务器时间响应: {}",response);
//		session.getIoSession().write(response);
//
//		return null;
//	}

}
